/*
 * @Author: June
 * @Date: 2022-11-14 14:40:09
 * @LastEditors: June
 * @LastEditTime: 2023-05-23 15:14:29
 * @Description: 
 * 
 */
import defaultSettings from '@/settings'
import variables from '@/styles/element-variables.scss'

const { showSettings, tagsView, fixedHeader, sidebarLogo ,layoutSettings,themeNumber} = defaultSettings
const type = localStorage.getItem('themeNumber')  ? +localStorage.getItem('themeNumber')  : themeNumber
const state = {
  theme: variables.theme,
  showSettings: showSettings,
  tagsView: tagsView,
  fixedHeader: fixedHeader,
  sidebarLogo: sidebarLogo,
  layoutSettings: layoutSettings,
  themeNumber:type|| type === 0 ? type : themeNumber
}

const mutations = {
  CHANGE_SETTING: (state, { key, value }) => {
    // eslint-disable-next-line no-prototype-builtins
    if (state.hasOwnProperty(key)) {
      state[key] = value
    }
  }
}

const actions = {
  changeSetting({ commit }, data) {
    commit('CHANGE_SETTING', data)
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}

